decimal

type decimal

A data type for representing real numbers with high precision. Uses java.math.BigDecimal internally.

Since

0.9.1

Constructors

Link copied to clipboard
pure constructor(value: text)

Creates a decimal from a text representation.

pure constructor(value: integer)

Creates a decimal from an integer.

pure constructor(value: big_integer)

Creates a decimal from a big_integer.

Properties

Link copied to clipboard
val INT_DIGITS: integer = 131072

The maximum number of digits before the decimal point (131072)

Link copied to clipboard
val MAX_VALUE: decimal = 1e+131072

The largest value that you can store in a decimal (1E+131072 - 1)

Link copied to clipboard
val MIN_VALUE: decimal = 1.0E-20

The smallest nonzero absolute value that a decimal can store

Link copied to clipboard
val PRECISION: integer = 131092

The maximum number of decimal digits (131072 + 20)

Link copied to clipboard
val SCALE: integer = 20

The maximum number of decimal digits after the decimal point (20)

Functions

Link copied to clipboard
pure function abs(): decimal

Absolute value of the decimal.

Link copied to clipboard
pure function ceil(): decimal

Ceiling value: rounds 1.0 to 1.0, 1.00001 to 2.0, -1.99999 to -1.0, etc.

Link copied to clipboard
pure function floor(): decimal

Floor value: rounds 1.0 to 1.0, 1.9999 to 1.0, -1.0001 to -2.0, etc.

Link copied to clipboard
pure static function from_text(value: text): decimal

Creates a decimal from a text representation.

Link copied to clipboard
pure function max(value: decimal): decimal

Maximum of two decimal values.

Link copied to clipboard
pure function min(value: decimal): decimal

Minimum of two decimal values.

Link copied to clipboard
pure function round(): decimal

Rounds up to the nearest integer number.

pure function round(digits: integer): decimal

Rounds to a specific number of decimal places.

Example:

>>> (123.456).round(-1)
120
>>> (123.456).round(1)
123.5
Link copied to clipboard
pure function sign(): integer

Returns -1, 0, or 1 depending on the sign.

Link copied to clipboard
(alias) pure function signum(): integer

Returns -1, 0, or 1 depending on the sign.

Alias
Link copied to clipboard
pure function to_big_integer(): big_integer

Converts this decimal to a big_integer by truncating the fractional part.

Link copied to clipboard
pure function to_integer(): integer

Converts this decimal to an integer by rounding towards 0. Throws and exception if out of range.

Link copied to clipboard
pure function to_text(): text

Converts this decimal to a string representation.

pure function to_text(scientific: boolean): text

Converts this decimal to a string representation, optionally using scientific notation (e.g.: 1.2345E+100).